package com.pow.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.pow.entity.Role;
import com.pow.service.impl.RoleServiceImpl;

@RestController
@RequestMapping("role")
public class RoleController {

	@Autowired
	private RoleServiceImpl roleService;
	@GetMapping
	public Object getAllRole(Role r,String name,Integer page,Integer limit,Pageable pageable) {
		return roleService.getAllRolesByRole(r, pageable, page, limit);
	}
	
	@DeleteMapping
	public Object deleteRole(String id) {
		return roleService.deleteRoleById(id);
	}
	@PostMapping
	public Object addRole(Role r) {
		return roleService.addRole(r);
	}
	@PutMapping
	public Object updateRole(Role r) {
		return roleService.updateRole(r);
	}
	
}
